#!/bin/bash

es_url=http://10.244.0.53:9200
km_indices=false 
chat_indices=pressqa 
itsm_indices=pressitsm 
message_indices=pressmessage 


if [ $km_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${km_indices}" -d @km-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${km_indices}"/knowledge/_mapping -d @km-mapping.json
fi

if [ $chat_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${chat_indices}" -d @chat-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${chat_indices}"/qa/_mapping -d @chat-mapping.json
fi

if [ $itsm_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${itsm_indices}" -d @itsm-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${itsm_indices}"/_mapping/event -d @itsm-mapping.json
fi

if [ $message_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${message_indices}" -d @message-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${message_indices}"/message/_mapping -d @message-mapping.json
fi
